<template>
  <div class="sub_menu" 
   @mouseover="onShowSubMenuItem"
   @mouseleave="onHideSubMenuItem"
  >
    <div class="men_title">
      <!-- 标题的插槽 -->
      <slot name="menu_title"></slot>
      <span class="icon">&gt;</span>
    </div>
    <!-- 子菜单 -->
    <div class="subMenItem_container" v-show="isShowMenuItem">
        <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MySubMenu',
  data() {
    return {
      isShowMenuItem: false,
    }
  },
  methods: {
    onShowSubMenuItem () {
      this.isShowMenuItem = true;
    },
    onHideSubMenuItem () {
      this.isShowMenuItem = false
    }
  },
}
</script>

<style lang="scss" scoped>
.sub_menu {
  position: relative;
  width: 100%;
  .men_title {
    position: relative;
    width: 100%;
    height: 50px;
    line-height: 50px;
    text-align: center;
    background-color: pink;
    .icon {
      position: absolute;
      right: 10px;
    }
  }  
  .subMenItem_container {
    position: absolute;
    top: 0;
    left: 100%;
    width: 100%;
    background-color: #000;
    .menu_item {
      height: 50px;
      line-height: 50px;
      text-align: center;
    }
  }
}
</style>